#include <iostream>


template<typename T>
class ArrayIterator {
public:
    // 定义类型别名
    using value_type = T;
    using pointer = T*;
    using reference = T&;

private:
    pointer ptr;  // 指向数组元素的指针

public:
    ArrayIterator(pointer p) : ptr(p) {}

    // 前缀递增
    ArrayIterator& operator++() {
        ptr++;
        return *this;
    }

    // 后缀递增
    ArrayIterator operator++(int) {
        ArrayIterator temp = *this;
        ++(*this);
        return temp;
    }

    // 解引用
    reference operator*() const {
        return *ptr;
    }

    // 指针访问
    pointer operator->() {
        return ptr;
    }

    // 等于
    bool operator==(const ArrayIterator& other) const {
        return ptr == other.ptr;
    }

    // 不等于
    bool operator!=(const ArrayIterator& other) const {
        return ptr != other.ptr;
    }
};

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    ArrayIterator<int> begin(arr);
    ArrayIterator<int> end(arr + sizeof(arr)/sizeof(arr[0]));

    for (ArrayIterator<int> it = begin; it != end; ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;
}